import request from '@/config/axios'
import type { Dayjs } from 'dayjs';

/** 班级成员信息 */
export interface ClassMember {
          id: number; // 班级成员唯一ID
          classId?: number; // 班级ID
          userId?: number; // 用户ID
          joinTime?: string | Dayjs; // 加入班级时间
          status?: number; // 成员状态（正常/已移除等）
          creator: string; // 创建者
          createTime: string | Dayjs; // 创建时间
          updater: string; // 更新者
          updateTime: string | Dayjs; // 更新时间
          deleted: boolean; // 是否删除
  }

// 班级成员 API
export const ClassMemberApi = {
  // 查询班级成员分页
  getClassMemberPage: async (params: any) => {
    return await request.get({ url: `/pickbook/class-member/page`, params })
  },

  // 查询班级成员详情
  getClassMember: async (id: number) => {
    return await request.get({ url: `/pickbook/class-member/get?id=` + id })
  },

  // 新增班级成员
  createClassMember: async (data: ClassMember) => {
    return await request.post({ url: `/pickbook/class-member/create`, data })
  },

  // 修改班级成员
  updateClassMember: async (data: ClassMember) => {
    return await request.put({ url: `/pickbook/class-member/update`, data })
  },

  // 删除班级成员
  deleteClassMember: async (id: number) => {
    return await request.delete({ url: `/pickbook/class-member/delete?id=` + id })
  },

  /** 批量删除班级成员 */
  deleteClassMemberList: async (ids: number[]) => {
    return await request.delete({ url: `/pickbook/class-member/delete-list?ids=${ids.join(',')}` })
  },

  // 导出班级成员 Excel
  exportClassMember: async (params) => {
    return await request.download({ url: `/pickbook/class-member/export-excel`, params })
  }
}